package com.lili.operate.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.operate.entity.distribution.DistributionGoods;
import com.lili.operate.mapper.DistributionGoodsMapper;
import com.lili.operate.service.DistributionGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DistributionGoodsServiceImpl implements DistributionGoodsService {

    @Autowired
    DistributionGoodsMapper distributionGoodsMapper;
    @Override
    public int saveDistributionGoods(DistributionGoods distributionGoods) {
        return distributionGoodsMapper.insert(distributionGoods);
    }

    /**
     * 分页查询所有的信息
     * @return
     */
    @Override
    public Page<DistributionGoods> queryAllDistributionGoods(int current,int pageSize) {

        //第一个是Page类型的（分页对象），第二个是Wapper类型的，因此我们创建这两个对象
        //current:当前页 size: 每页有多少条记录
        Page<DistributionGoods> page = new Page<>(current,pageSize);
        distributionGoodsMapper.selectPage(page,null);
//        List<DistributionGoods> list = distributionGoodsMapper.queryAllDistributionGoods();
        return page;
    }

    @Override
    public int updateDistributionGoods(String id) {
        return 0;
    }
}
